package com.ddwl.goods.controller.bargain;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.goods.service.bargain.BargainConfigService;
import com.ddwl.schema.bo.goods.bargain.BargainConfigAddBo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.goods.bargain.BargainConfigVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Author hemiaojun
 * @Date 2020/11/6 13:49
 */
@RestController
@RequestMapping("/bargainConfig")
@Api(tags = "砍价活动全局配置")
public class BargainConfigController extends BaseController {

    @Resource
    private BargainConfigService bargainConfigService;

    @PostMapping("/save")
    @Auth(product={BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("新增砍价活动全局配置")
    public RestVo add(@RequestBody @Valid BargainConfigAddBo bo){
        bargainConfigService.save(bo);
        return RestVo.ok();
    }

    @GetMapping("/get")
    @Auth(product={BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("砍价活动全局配置详情")
    public RestVo<BargainConfigVo> get(@RequestParam(required = false) String shopId){
        return RestVo.ok(bargainConfigService.getBargainConfig(shopId));
    }


}
